﻿using Ruici.BLL;
using RuiciWebSite.Models;
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using RuiciWebSite.Common;
using System.Configuration;
using System.IO;
using System.Linq;
using Ruici.Web.Services.CRS_Service;
using Ruici.Web.Services.Model;
using System.Xml;
using System.Data;

namespace RuiciWebSite.Controllers
{
    public class HomeController : Controller
    {
        private readonly DocInfoBll _docInfoBll;
        private RuiciCommoms common = new RuiciCommoms();
        public static string docImageUrl = ConfigurationManager.AppSettings["ImageUrl"];

        public HomeController()
        {
            _docInfoBll = new DocInfoBll();
        }

        public ActionResult Index()
        {
            return View();
        }

        #region  
        [HttpGet]
        public JsonResult GetHomeLogoImages()
        {
            List<ImageViewModel> homeImageList = new List<ImageViewModel>();

            var servicesrc = Request.Url.Scheme + "://" + Request.Url.Authority;

            XmlDocument doc = new XmlDocument();
            doc.Load(Server.MapPath("~/XmlExtension/HomeLogoXMLFile.xml"));
            
            XmlElement root = null;
            root = doc.DocumentElement;
            XmlNodeList listNodes = root.SelectNodes("/iamgeList/imagelistitem");
            foreach (XmlNode node in listNodes)
            {
                ImageViewModel imageViewModel = new ImageViewModel();
                imageViewModel.ImgUrl = servicesrc + node.SelectSingleNode("ImgUrl").InnerText;
                imageViewModel.Url = node.SelectSingleNode("Url").InnerText;
                imageViewModel.TypeNumber = node.SelectSingleNode("TypeNumber").InnerText;
                imageViewModel.TitleName = node.SelectSingleNode("TitleName").InnerText;

                homeImageList.Add(imageViewModel);
            }
            
            return Json(homeImageList, JsonRequestBehavior.AllowGet);
        }


        [HttpGet]
        public JsonResult GetArticLists()
        {
            List<ArticleViewModel> articList = new List<ArticleViewModel>();
            int totalcount;
            var articLists = _docInfoBll.GetArticleList("clinics_news", 251, 5, 1, "", "", out totalcount);
            articList = articLists.Select(m => new ArticleViewModel
            {
                id = m.id,
                channel_id = m.channel_id,
                category_id = m.category_id,
                call_index = m.call_index,
                title = m.title,
                link_url = m.link_url,
                img_url = m.img_url,
                seo_title = m.seo_title,
                seo_keywords = m.seo_keywords,
                seo_description = m.seo_description,
                zhaiyao = string.IsNullOrWhiteSpace(m.zhaiyao) ? "" : m.zhaiyao.Replace("&amp;", "").Replace("&emsp;", "").Replace("emsp;", ""),
                content = m.content,
                sort_id = m.sort_id,
                click = m.click,
                status = m.status,
                is_msg = m.is_msg,
                is_top = m.is_top,
                is_red = m.is_red,
                is_hot = m.is_hot,
                is_slide = m.is_slide,
                is_sys = m.is_sys,
                user_name = m.user_name
            }).ToList();
            return Json(articList, JsonRequestBehavior.AllowGet);
        }

        [HttpGet]
        public JsonResult GetNewsLists()
        {
            List<ArticleViewModel> newsList = new List<ArticleViewModel>();
            int totalcount;
            var articLists = _docInfoBll.GetArticleList("clinics_news", 252, 5, 1, "", "", out totalcount);
            newsList = articLists.Select(m => new ArticleViewModel
            {
                id = m.id,
                channel_id = m.channel_id,
                category_id = m.category_id,
                call_index = m.call_index,
                title = m.title,
                link_url = m.link_url,
                img_url = m.img_url,
                seo_title = m.seo_title,
                seo_keywords = m.seo_keywords,
                seo_description = m.seo_description,
                zhaiyao = string.IsNullOrWhiteSpace(m.zhaiyao) ? "" : m.zhaiyao.Replace("&amp;", "").Replace("&emsp;", "").Replace("emsp;", ""),
                content = m.content,
                sort_id = m.sort_id,
                click = m.click,
                status = m.status,
                is_msg = m.is_msg,
                is_top = m.is_top,
                is_red = m.is_red,
                is_hot = m.is_hot,
                is_slide = m.is_slide,
                is_sys = m.is_sys,
                user_name = m.user_name
            }).ToList();
            return Json(newsList, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 获取当前周
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public JsonResult GetCurrentWeekDate()
        {

            DateTime currentdate = DateTime.Now;  //当前时间
            DateTime startweek = currentdate.AddDays(1 - Convert.ToInt32(currentdate.DayOfWeek.ToString("d")));  //本周周一

            DateWeek dateWeek = new DateWeek();
            dateWeek.Monday = startweek.ToString("MM-dd");
            dateWeek.Tuesday = startweek.AddDays(1).ToString("MM-dd");
            dateWeek.Wednesday = startweek.AddDays(2).ToString("MM-dd");
            dateWeek.Thursday = startweek.AddDays(3).ToString("MM-dd");
            dateWeek.Friday = startweek.AddDays(4).ToString("MM-dd");
            dateWeek.Saturday = startweek.AddDays(5).ToString("MM-dd");

            dateWeek.IsMondayDisable = CompareDate(startweek);
            dateWeek.IsTuesdayDisable = CompareDate(startweek.AddDays(1));
            dateWeek.IsWednesdayDisable = CompareDate(startweek.AddDays(2));
            dateWeek.IsThursdayDisable = CompareDate(startweek.AddDays(3));
            dateWeek.IsFridayDisable = CompareDate(startweek.AddDays(4));
            dateWeek.IsSaturdayDisable = CompareDate(startweek.AddDays(5));

            dateWeek.Year = startweek.Year.ToString();
            dateWeek.SelectedDate = DateTime.Now.ToString("MM-dd");
            return Json(dateWeek, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 获取上一周
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetLastWeekDate(string datepoint, string year)
        {
            var datetemp = year + "-" + datepoint;
            DateTime currentdate = DateTime.Compare(Convert.ToDateTime(datetemp), DateTime.Now) > 0 ? Convert.ToDateTime(datetemp) : DateTime.Now;  //当前时间
            DateTime startweek = new DateTime();
            if (DateTime.Compare(Convert.ToDateTime(datetemp), DateTime.Now) > 0)
            {
                startweek = currentdate.AddDays(-6 - Convert.ToInt32(currentdate.DayOfWeek.ToString("d")));  //本周周一
            }
            else
            {
                startweek = currentdate.AddDays(1 - Convert.ToInt32(currentdate.DayOfWeek.ToString("d")));  //本周周一 
            }

            DateWeek dateWeek = new DateWeek();
            dateWeek.Monday = startweek.ToString("MM-dd");
            dateWeek.Tuesday = startweek.AddDays(1).ToString("MM-dd");
            dateWeek.Wednesday = startweek.AddDays(2).ToString("MM-dd");
            dateWeek.Thursday = startweek.AddDays(3).ToString("MM-dd");
            dateWeek.Friday = startweek.AddDays(4).ToString("MM-dd");
            dateWeek.Saturday = startweek.AddDays(5).ToString("MM-dd");

            dateWeek.IsMondayDisable = CompareDate(startweek);
            dateWeek.IsTuesdayDisable = CompareDate(startweek.AddDays(1));
            dateWeek.IsWednesdayDisable = CompareDate(startweek.AddDays(2));
            dateWeek.IsThursdayDisable = CompareDate(startweek.AddDays(3));
            dateWeek.IsFridayDisable = CompareDate(startweek.AddDays(4));
            dateWeek.IsSaturdayDisable = CompareDate(startweek.AddDays(5));

            dateWeek.Year = startweek.Year.ToString();
            dateWeek.SelectedDate = DateTime.Compare(Convert.ToDateTime(startweek), DateTime.Now) > 0 ? startweek.ToString("MM-dd") : DateTime.Now.ToString("MM-dd");
            return Json(dateWeek, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 获取下一周
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetNextWeekDate(string datepoint, string year)
        {
            var datetemp = year + "-" + datepoint;
            DateTime currentdate = Convert.ToDateTime(datetemp);  //当前时间
            DateTime startweek = currentdate.AddDays(8 - Convert.ToInt32(currentdate.DayOfWeek.ToString("d")));  //本周周一

            DateWeek dateWeek = new DateWeek();
            dateWeek.Monday = startweek.ToString("MM-dd");
            dateWeek.Tuesday = startweek.AddDays(1).ToString("MM-dd");
            dateWeek.Wednesday = startweek.AddDays(2).ToString("MM-dd");
            dateWeek.Thursday = startweek.AddDays(3).ToString("MM-dd");
            dateWeek.Friday = startweek.AddDays(4).ToString("MM-dd");
            dateWeek.Saturday = startweek.AddDays(5).ToString("MM-dd");

            dateWeek.IsMondayDisable = CompareDate(startweek);
            dateWeek.IsTuesdayDisable = CompareDate(startweek.AddDays(1));
            dateWeek.IsWednesdayDisable = CompareDate(startweek.AddDays(2));
            dateWeek.IsThursdayDisable = CompareDate(startweek.AddDays(3));
            dateWeek.IsFridayDisable = CompareDate(startweek.AddDays(4));
            dateWeek.IsSaturdayDisable = CompareDate(startweek.AddDays(5));

            dateWeek.Year = startweek.Year.ToString();
            dateWeek.SelectedDate = DateTime.Compare(Convert.ToDateTime(startweek.AddDays(6)), DateTime.Now) > 0 ? startweek.ToString("MM-dd") : DateTime.Now.ToString("MM-dd");
            return Json(dateWeek, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 所有专家列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public JsonResult GetDoctorList()
        {
            List<RecentVisitExpertsViewModel> doctorList = new List<RecentVisitExpertsViewModel>();

            var doctorOnTimeInfos = _docInfoBll.GetDoctorScheduleByDate(-1, DateTime.Now, DateTime.Now);
            if (doctorOnTimeInfos.Count > 0)
            {
                List<int> doctoridlist = new List<int>();

                foreach (var item in doctorOnTimeInfos)
                {
                    doctoridlist.Add(item.docID);
                }

                var temp = doctoridlist.Select(x => "'" + x + "'");
                string doctorid = string.Join(",", temp);
                var doctorInfoList = _docInfoBll.GetDoctorListById(doctorid);
                if (doctorInfoList != null)
                {
                    foreach (var item in doctorInfoList)
                    {
                        RecentVisitExpertsViewModel doctorInfo = new RecentVisitExpertsViewModel();
                        doctorInfo.Id = item.id;
                        doctorInfo.AffiliatedHospital = item.affiliatedHospital;
                        doctorInfo.Name = item.name;
                        doctorInfo.TitleName = item.titleName;
                        doctorInfo.DeptName = item.deptName;
                        doctorInfo.DepName2 = item.depName2;
                        doctorInfo.SkillIn = string.IsNullOrWhiteSpace(item.skillIn) ? "" : item.skillIn;
                        doctorInfo.Image = docImageUrl + item.image;
                        doctorInfo.OrgName = item.orgName;
                        doctorInfo.DeptId = item.deptID;
                        doctorList.Add(doctorInfo);
                    }

                }
                doctorList = doctorList.OrderBy(o => o.DepName2).ThenBy(o => o.TitleName).ThenBy(o => o.Name).ToList();
            }
            return Json(doctorList, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 近期出诊专家列表
        /// </summary>
        /// <param name="datepoint"></param>
        /// <param name="year"></param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetDoctorLists(string datepoint, string year)
        {
            var datetemp = year + "-" + datepoint;
            DateTime selecteddate = Convert.ToDateTime(datetemp);  //当前时间

            List<RecentVisitExpertsViewModel> doctorList = new List<RecentVisitExpertsViewModel>();

            var doctorOnTimeInfos = _docInfoBll.GetDoctorScheduleByDate(-1, selecteddate, selecteddate);
            if (doctorOnTimeInfos.Count > 0)
            {
                List<int> doctoridlist = new List<int>();

                foreach (var item in doctorOnTimeInfos)
                {
                    doctoridlist.Add(item.docID);
                }

                var temp = doctoridlist.Select(x => "'" + x + "'");
                string doctorid = string.Join(",", temp);
                var doctorInfoList = _docInfoBll.GetDoctorListById(doctorid);
                if (doctorInfoList != null)
                {
                    foreach (var item in doctorInfoList)
                    {
                        RecentVisitExpertsViewModel doctorInfo = new RecentVisitExpertsViewModel();
                        doctorInfo.Id = item.id;
                        doctorInfo.AffiliatedHospital = item.affiliatedHospital;
                        doctorInfo.Name = item.name;
                        doctorInfo.TitleName = item.titleName;
                        doctorInfo.DeptName = item.deptName;
                        doctorInfo.DepName2 = item.depName2;
                        doctorInfo.SkillIn = string.IsNullOrWhiteSpace(item.skillIn) ? "" : item.skillIn;
                        doctorInfo.Image = docImageUrl + item.image;
                        doctorInfo.OrgName = item.orgName;
                        doctorInfo.DeptId = item.deptID;
                        doctorList.Add(doctorInfo);
                    }

                }
                doctorList = doctorList.OrderBy(o => o.DepName2).ThenBy(o => o.TitleName).ThenBy(o => o.Name).ToList();
            }
            return Json(doctorList, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 排班日期属性
        /// </summary>
        public class DateWeek
        {
            /// <summary>
            /// 周一
            /// </summary>
            public string Monday { get; set; }
            /// <summary>
            /// 周二
            /// </summary>

            public string Tuesday { get; set; }
            /// <summary>
            /// 周三
            /// </summary>

            public string Wednesday { get; set; }
            /// <summary>
            /// 周四
            /// </summary>

            public string Thursday { get; set; }
            /// <summary>
            /// 周五
            /// </summary>

            public string Friday { get; set; }
            /// <summary>
            /// 周六
            /// </summary>

            public string Saturday { get; set; }
            /// <summary>
            /// 周一是否禁用
            /// </summary>

            public bool IsMondayDisable { get; set; }
            /// <summary>
            /// 周二是否禁用
            /// </summary>

            public bool IsTuesdayDisable { get; set; }
            /// <summary>
            /// 周三是否禁用
            /// </summary>

            public bool IsWednesdayDisable { get; set; }
            /// <summary>
            /// 周四是否禁用
            /// </summary>

            public bool IsThursdayDisable { get; set; }
            /// <summary>
            /// 周五是否禁用
            /// </summary>

            public bool IsFridayDisable { get; set; }
            /// <summary>
            /// 周六是否禁用
            /// </summary>
            public bool IsSaturdayDisable { get; set; }
            /// <summary>
            /// 年份
            /// </summary>

            public string Year { get; set; }
            /// <summary>
            /// 选中的日期
            /// </summary>
            public string SelectedDate { get; set; }
        }
        /// <summary>
        /// 日期比较
        /// </summary>
        /// <param name="selectdate"></param>
        /// <returns></returns>
        private bool CompareDate(DateTime selectdate)
        {
            var isdisable = true;

            if (DateTime.Compare(selectdate.Date, DateTime.Now.Date) >= 0)
            {
                isdisable = false;
            }
            return isdisable;
        }

        #endregion
        /// <summary>
        /// 核对登录状态
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult CheckLoginStatus()
        {
            loginInfo logInfo = common.checkLoginStatus(Request, Response,Session);
            return Json(logInfo, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 登出
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public JsonResult LoginOut()
        {
            loginInfo logInfo = common.userLogout(Request, Response, Session);

            return Json(logInfo, JsonRequestBehavior.AllowGet);
        }

        #region search
        /// <summary>
        /// 根据帅选获取的医生信息
        /// </summary>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetDoctorInfoByFilter(OrderExpertPageInfoViewModel pageInfo)
        {
            List<RecentVisitExpertsViewModel> doctorList = new List<RecentVisitExpertsViewModel>();
            if (!string.IsNullOrWhiteSpace(pageInfo.keyWord))
            {
                pageInfo.pageSize = 100;
                var doctorinfolist = _docInfoBll.GetDoctorList(pageInfo.deptId, pageInfo.titleId, pageInfo.keyWord, pageInfo.pageCount, pageInfo.pageSize);
                if (doctorinfolist.Count > 0)
                {
                    foreach (var item in doctorinfolist)
                    {
                        RecentVisitExpertsViewModel docinfo = new RecentVisitExpertsViewModel();
                        var docinfoget = _docInfoBll.GetDoctor(item.id.ToString());
                        docinfo.Id = docinfoget.id;
                        docinfo.AffiliatedHospital = docinfoget.affiliatedHospital;
                        docinfo.Name = docinfoget.name;
                        docinfo.TitleName = docinfoget.titleName;
                        docinfo.DeptName = docinfoget.deptName;
                        docinfo.DepName2 = docinfoget.depName2;
                        docinfo.DeptId = docinfoget.deptID;
                        docinfo.SkillIn = string.IsNullOrWhiteSpace(docinfoget.skillIn) ? "" : docinfoget.skillIn;
                        docinfo.Image = docImageUrl + docinfoget.image;
                        docinfo.OrgName = docinfoget.orgName;

                        doctorList.Add(docinfo);
                    }
                }
            }

            return Json(doctorList, JsonRequestBehavior.AllowGet);
        }

        [HttpPost]
        public JsonResult GetVideoListsByFilter(string searchKeys)
        {
            List<DoctorArticleInfo> articList = new List<DoctorArticleInfo>();
            int totalcount;
            if (!string.IsNullOrWhiteSpace(searchKeys))
            {
                var articLists = _docInfoBll.GetArticleListForDoctor("video", 0, 10, 1, searchKeys, "", out totalcount);
                articList = articLists.Select(m => new DoctorArticleInfo
                {
                    id = m.id,
                    channel_id = m.channel_id,
                    category_id = m.category_id,
                    call_index = m.call_index,
                    title = m.title,
                    link_url = m.link_url,
                    img_url = docImageUrl + m.img_url,
                    seo_title = m.seo_title,
                    seo_keywords = m.seo_keywords,
                    seo_description = m.seo_description,
                    zhaiyao = string.IsNullOrWhiteSpace(m.zhaiyao) ? "" : m.zhaiyao.Replace("&amp;", "").Replace("&emsp;", "").Replace("emsp;", ""),
                    content = m.content,
                    sort_id = m.sort_id,
                    click = m.click,
                    status = m.status,
                    is_msg = m.is_msg,
                    is_top = m.is_top,
                    is_red = m.is_red,
                    is_hot = m.is_hot,
                    is_slide = m.is_slide,
                    is_sys = m.is_sys,
                    update_time = m.update_time,
                    videoSrc = m.videoSrc,
                    fileSrc = m.fileSrc,
                    user_name = m.user_name,
                    doctor_id = m.doctorID
                }).ToList();
            }

            RuiciCommoms.doctorIdList.RemoveAll(i => true);
            foreach (DoctorArticleInfo doc in articList)
            {
                if (!RuiciCommoms.doctorIdList.Exists(i => i == doc.doctor_id))
                {
                    RuiciCommoms.doctorIdList.Add(doc.doctor_id);
                }
            }

            return Json(articList, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 相关疾病大全
        /// </summary>
        /// <param name="expertDetailViewModel"></param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetArticleListsByFilter(string searchKeys)
        {
            List<DoctorArticleInfo> articList = new List<DoctorArticleInfo>();
            int totalcount;
            if (!string.IsNullOrWhiteSpace(searchKeys))
            {
                var articLists = _docInfoBll.GetArticleListForDoctor("disease", 0, 100, 1, searchKeys, "", out totalcount);
                var caseLists = _docInfoBll.GetArticleListForDoctor("case", 0, 100, 1, searchKeys, "", out totalcount);

                DocumentBll document = new DocumentBll();
                var clinicsNewsLists = document.GetArticleList("clinics_news", 0, 100, 1, searchKeys, out totalcount);

                articList = articLists.Select(m => new DoctorArticleInfo
                {
                    id = m.id,
                    channel_id = m.channel_id,
                    category_id = m.category_id,
                    call_index = m.call_index,
                    title = m.title,
                    link_url = m.link_url,
                    img_url = docImageUrl + m.img_url,
                    seo_title = m.seo_title,
                    seo_keywords = m.seo_keywords,
                    seo_description = m.seo_description,
                    zhaiyao = string.IsNullOrWhiteSpace(m.zhaiyao) ? "" : m.zhaiyao.Replace("&amp;", "").Replace("&emsp;", "").Replace("emsp;", ""),
                    content = m.content,
                    sort_id = m.sort_id,
                    click = m.click,
                    status = m.status,
                    is_msg = m.is_msg,
                    is_top = m.is_top,
                    is_red = m.is_red,
                    is_hot = m.is_hot,
                    is_slide = m.is_slide,
                    is_sys = m.is_sys,
                    update_time = m.update_time,
                    videoSrc = m.videoSrc,
                    fileSrc = m.fileSrc,
                    user_name = m.user_name
                }).ToList();

                foreach (ArticleResponse articleInfo in clinicsNewsLists)
                {
                    DoctorArticleInfo article = new DoctorArticleInfo();
                    article.id = articleInfo.id;
                    article.channel_id = articleInfo.channel_id;
                    article.category_id = articleInfo.category_id;
                    article.call_index = articleInfo.call_index;
                    article.title = articleInfo.title;
                    article.link_url = articleInfo.link_url;
                    article.img_url = docImageUrl + articleInfo.img_url;
                    article.seo_title = articleInfo.seo_title;
                    article.seo_keywords = articleInfo.seo_keywords;
                    article.seo_description = articleInfo.seo_description;
                    article.zhaiyao = string.IsNullOrWhiteSpace(articleInfo.zhaiyao) ? "" : articleInfo.zhaiyao.Replace("&amp;", "").Replace("&emsp;", "").Replace("emsp;", "");
                    article.content = articleInfo.content;
                    article.sort_id = articleInfo.sort_id;
                    article.click = articleInfo.click;
                    article.status = articleInfo.status;
                    article.is_msg = articleInfo.is_msg;
                    article.is_top = articleInfo.is_top;
                    article.is_red = articleInfo.is_red;
                    article.is_hot = articleInfo.is_hot;
                    article.is_slide = articleInfo.is_slide;
                    article.is_sys = articleInfo.is_sys;
                    article.update_time = articleInfo.update_time;
                    article.videoSrc = articleInfo.videoSrc;
                    article.fileSrc = articleInfo.fileSrc;
                    article.user_name = articleInfo.user_name;
                    articList.Add(article);
                }

                foreach (ArticleResponse articleInfo in caseLists)
                {
                    DoctorArticleInfo article = new DoctorArticleInfo();
                    article.id = articleInfo.id;
                    article.channel_id = articleInfo.channel_id;
                    article.category_id = articleInfo.category_id;
                    article.call_index = articleInfo.call_index;
                    article.title = articleInfo.title;
                    article.link_url = articleInfo.link_url;
                    article.img_url = docImageUrl + articleInfo.img_url;
                    article.seo_title = articleInfo.seo_title;
                    article.seo_keywords = articleInfo.seo_keywords;
                    article.seo_description = articleInfo.seo_description;
                    article.zhaiyao = string.IsNullOrWhiteSpace(articleInfo.zhaiyao) ? "" : articleInfo.zhaiyao.Replace("&amp;", "").Replace("&emsp;", "").Replace("emsp;", "");
                    article.content = articleInfo.content;
                    article.sort_id = articleInfo.sort_id;
                    article.click = articleInfo.click;
                    article.status = articleInfo.status;
                    article.is_msg = articleInfo.is_msg;
                    article.is_top = articleInfo.is_top;
                    article.is_red = articleInfo.is_red;
                    article.is_hot = articleInfo.is_hot;
                    article.is_slide = articleInfo.is_slide;
                    article.is_sys = articleInfo.is_sys;
                    article.update_time = articleInfo.update_time;
                    article.videoSrc = articleInfo.videoSrc;
                    article.fileSrc = articleInfo.fileSrc;
                    article.user_name = articleInfo.user_name;
                    articList.Add(article);
                }
            }

            return Json(articList, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 相关指南共识
        /// </summary>
        /// <param name="expertDetailViewModel"></param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetGuideListsByFilter(string searchKeys)
        {
            List<DoctorArticleInfo> articList = new List<DoctorArticleInfo>();
            int totalcount;
            if (!string.IsNullOrWhiteSpace(searchKeys))
            {
                var articLists = _docInfoBll.GetArticleListForDoctor("guide", 0, 10, 1, searchKeys, "", out totalcount);
                articList = articLists.Select(m => new DoctorArticleInfo
                {
                    id = m.id,
                    channel_id = m.channel_id,
                    category_id = m.category_id,
                    call_index = m.call_index,
                    title = m.title,
                    link_url = m.link_url,
                    img_url = docImageUrl + m.img_url,
                    seo_title = m.seo_title,
                    seo_keywords = m.seo_keywords,
                    seo_description = m.seo_description,
                    zhaiyao = string.IsNullOrWhiteSpace(m.zhaiyao) ? "" : m.zhaiyao.Replace("&amp;", "").Replace("&emsp;", "").Replace("emsp;", ""),
                    content = m.content,
                    sort_id = m.sort_id,
                    click = m.click,
                    status = m.status,
                    is_msg = m.is_msg,
                    is_top = m.is_top,
                    is_red = m.is_red,
                    is_hot = m.is_hot,
                    is_slide = m.is_slide,
                    is_sys = m.is_sys,
                    update_time = m.update_time,
                    videoSrc = m.videoSrc,
                    fileSrc = m.fileSrc,
                    user_name = m.user_name
                }).ToList();
            }

            return Json(articList, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 相关新闻
        /// </summary>
        /// <param name="searchKeys"></param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetNewsListsByFilter(string searchKeys)
        {
            List<DoctorArticleInfo> clinicsNewsList = new List<DoctorArticleInfo>();
            int totalcount;
            if (!string.IsNullOrWhiteSpace(searchKeys))
            {
                DocumentBll document = new DocumentBll();
                var articLists = document.GetArticleList("clinics_news", 0, 100, 1, searchKeys, out totalcount);
                clinicsNewsList = articLists.Select(m => new DoctorArticleInfo
                {
                    id = m.id,
                    channel_id = m.channel_id,
                    category_id = m.category_id,
                    call_index = m.call_index,
                    title = m.title,
                    link_url = m.link_url,
                    img_url = docImageUrl + m.img_url,
                    seo_title = m.seo_title,
                    seo_keywords = m.seo_keywords,
                    seo_description = m.seo_description,
                    zhaiyao = string.IsNullOrWhiteSpace(m.zhaiyao) ? "" : m.zhaiyao.Replace("&amp;", "").Replace("&emsp;", "").Replace("emsp;", ""),
                    content = m.content,
                    sort_id = m.sort_id,
                    click = m.click,
                    status = m.status,
                    is_msg = m.is_msg,
                    is_top = m.is_top,
                    is_red = m.is_red,
                    is_hot = m.is_hot,
                    is_slide = m.is_slide,
                    is_sys = m.is_sys,
                    update_time = m.update_time,
                    videoSrc = m.videoSrc,
                    fileSrc = m.fileSrc,
                    user_name = m.user_name
                }).ToList();
            }

            return Json(clinicsNewsList, JsonRequestBehavior.AllowGet);
        }

        #endregion
    }
}